#ifndef WOBBLEPARAMS_H
#define WOBBLEPARAMS_H

#include <QSettings>
#include "jsonconvert.h"

class WobbleParams : public JsonConvert
{
public:
    WobbleParams(){}

    bool enabled()
    {
        return mEnabled;
    }

    void setEnabled(bool enabled)
    {
        mEnabled = enabled;
    }

    double transversal()
    {
        return mTransversal;
    }

    void setTransversal(double transversal)
    {
        mTransversal = transversal;
    }

    double longitudinal()
    {
        return mLongitudinal;
    }

    void setLongitudinal(double longitudinal)
    {
        mLongitudinal = longitudinal;
    }

    int frequency()
    {
        return mFrequency;
    }

    void setFrequency(int frequency)
    {
        mFrequency = frequency;
    }

    void readFromFile()
    {
        QSettings settings("GlobalLaser.ini", QSettings::IniFormat);
        settings.beginGroup("Wobble");
        this->mEnabled = settings.value("mEnabled").toBool();
        this->mTransversal = settings.value("mTransversal").toDouble();
        this->mLongitudinal = settings.value("mLongitudinal").toDouble();
        this->mFrequency = settings.value("mFrequency").toInt();
        settings.endGroup();
    }

    void writeToFile()
    {
        QSettings settings("GlobalLaser.ini", QSettings::IniFormat);
        settings.beginGroup("Wobble");
        settings.setValue("mEnabled",  mEnabled);
        settings.setValue("mTransversal",  mTransversal);
        settings.setValue("mLongitudinal",  mLongitudinal);
        settings.setValue("mFrequency",  mFrequency);
        settings.endGroup();
    }

    QJsonObject toJsonObj() const
    {
        QJsonObject obj;
        obj["mEnabled"] = mEnabled;
        obj["mTransversal"] = mTransversal;
        obj["mLongitudinal"] = mLongitudinal;
        obj["mFrequency"] = mFrequency;
        return obj;
    }

    void fromJsonObj(const QJsonObject& obj)
    {
        mEnabled = obj["mEnabled"].toBool();
        mTransversal = obj["mTransversal"].toDouble();
        mLongitudinal = obj["mLongitudinal"].toDouble();
        mFrequency = obj["mFrequency"].toInt();
    }

    bool operator ==(const WobbleParams& param){
        bool rel = true;
        rel &= (this->mEnabled == param.mEnabled);
        rel &= (this->mTransversal == param.mTransversal);
        rel &= (this->mLongitudinal == param.mLongitudinal);
        rel &= (this->mFrequency == param.mFrequency);
        return rel;
    }

    void operator =(const WobbleParams& param){
        this->mEnabled = param.mEnabled;
        this->mTransversal = param.mTransversal;
        this->mLongitudinal = param.mLongitudinal;
        this->mFrequency = param.mFrequency;
    }

private:
    bool mEnabled = false;
    double mTransversal = 0;
    double mLongitudinal = 0;
    int mFrequency = 0;


};

#endif // WOBBLEPARAMS_H
